﻿using System;
using NDBGen.Descriptors.Columns.Tokens;

namespace NDBGen.Descriptors.Columns.DataTypes
{
    [ColumnDataTypeDescriptor(DataType.Timestamp | DataType.Version)]
    public sealed class RowVersionDataTypeDescriptor : ColumnDataTypeDescriptorBase
    {
        private const String TOSTRING_FORMAT = "{0}|version";
        
        public override Boolean RequiresNullableModifier(IColumnTokenDescriptor[] descriptors)
        {
            return false;
        }

        public override String ToString()
        {
            return String.Format(TOSTRING_FORMAT, this.Column.Name);
        }

        public override Boolean Equals(Object obj)
        {
            var that = obj as RowVersionDataTypeDescriptor;
            if (that == null) return false;
            else return
                this.Column.Equals(that.Column);
        }

        public override Int32 GetHashCode()
        {
            return
                this.GetType().GetHashCode() ^
                this.Column.GetHashCode();
        }
    }
}